package day240925;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

@WebServlet("/day240925/hw-cookie")
public class HwCookieServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // req.getRequestDispatcher 方法的 path 参数是相对于当前 Servlet 路径的
        // 这个例子有点特色：@WebServlet 配置的路径不止一个层级，
        // 所以如果这里不加 "/" 而是直接写 "day240925/hw-cookie.jsp"，
        // 那它代表转发的时候要找的 jsp 路径是 /day240925/hw-cookie/day240925/hw-cookie.jsp，就会报 404 错误了
        req.getRequestDispatcher("/day240925/hw-cookie.jsp").forward(req, resp);
    }
}